﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    public class Cached
    {

         Dictionary<string, Dictionary<string, string>> cachedData = new Dictionary<string, Dictionary<string, string>>();
         public string ReadData(string section,string key)
         {
             if (cachedData.ContainsKey(section))
             {
                 if (cachedData[section].ContainsKey(key))
                 { 
                    return cachedData[section][key];
                 }
             }
             return "";
         }
         public string WriteData(string section, string key, string val)
         {
             try
             {
                 if (cachedData.ContainsKey(section))
                 {
                     if (cachedData[section].ContainsKey(key))
                     {
                         cachedData[section][key] = val;

                     }
                     else
                     {
                         cachedData[section].Add(key, val);
                     }
                 }
                 else
                 {
                     cachedData.Add(section, new Dictionary<string, string>());
                     cachedData[section].Add(key,val);
                 }
             }
             catch (Exception e)
             {
                 return e.Message;
             }
             return "";
         }
       
    }
}
